from django.contrib import admin
from . import models
# Register your models here.

class BookAdmin(admin.ModelAdmin):
    # 要展示的类别
    list_display = ("id","name","price","author")

    # ordering设置默认排序字段，负号表示降序排序
    ordering = ("id",)

    # list_editable 设置默认可编辑字段
    list_editable = ['name','author','price']

    # 设置每页显示多少条数据，默认100
    list_per_page = 2

    # 搜索字段
    search_fields = ("name","age","email")

    # 过滤器
    list_filter = ("name","author","price")

    # 详细时间分层筛选
    date_hierarchy = "时间字段"


# 注册
admin.site.register(models.Book,BookAdmin)